#ifndef __TIMER_H__
#define __TIMER_H__

#include <set>
#include "common.h"

class NTDTimer;

class INTDTimerListener{
public:
	virtual void OnTimer(NTDTimer* pTimer) = 0;
};

class NTDTimer
{
public:
	NTDTimer();
	virtual ~NTDTimer();

	void Start(int32 ms, bool cycle);
	void Stop();

	void AddListener(INTDTimerListener * listener);
	void RemoveListener(INTDTimerListener * listener);

	void OnTimer();

private:
	std::set<INTDTimerListener *> listener_set_;
	struct event *timeout_event_;
};

#endif//__TIMER_H__